<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<JobSearchData>" %>
<%@ Import Namespace="RecruitmentAgency.Models.DataTypes"%>
<%@ Import Namespace="RecruitmentAgency.Models.Utilities.Paging"%>

<asp:Content ContentPlaceHolderID="Head" ID="head" runat="server">
 <script type="text/javascript">
     $(document).ready(function() {
         $("#ClosingDate").datepicker({ changeMonth: true, changeYear: true });
     }); 
  </script>
</asp:Content>
<asp:Content ID="MenuLinks" ContentPlaceHolderID="PageMenu" runat="server">
    <div class="centre">
        <% if (ViewData["role"].ToString() == "JobProvider") { %><div class="subMenuButton" onmouseover="swapBgImage(this)" onclick="javascript:location.href='/Job/Create'" onmouseout="swapBgImage(this)">Add job</div><% } %>
        <img src="../../Images/RssLogo.png" class="rssLink inline" alt= "Rss logo" onmouseover="swapImage(this)" onmousedown="javascript:location.href='/Job/JobRssFeed'" onmouseout="swapImage(this)" />
    </div>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Connections - View Jobs
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <% using (Html.BeginForm()) {%>
        <div class="panelTop"></div>            
        <div class="panelMiddle padLR20">
            <div class="titleLabel">Search job positions</div>
            <div class="formColumn">                    
                <div class="formLabel">
                    <label for="JobTitle">Job title :</label>
                </div>
                <%= Html.TextBox("JobTitle")%>                               
                <div class="formLabel">
                    <label for="ClosingDate">Closing date:</label>
                </div>
                <%= Html.TextBox("ClosingDate")%>             
            </div>
            <div class="formColumn">
                <div class="formLabel">
                    <label for="JobSector">Job sector:</label>
                </div>
                <%= Html.DropDownList("JobSector", (SelectList)ViewData["sectors"], new { @class = "dropDownList" })%>
               <div class="formLabel">
                    <label for="JobDescription">Job description:</label>
                </div>
                <%= Html.TextBox("JobDescription")%>                                             
                <input name="searchJobButton" class="formButton" id="searchJobButton" type="submit" value="Search" />
            </div>
        </div>
        <div class="panelBottom"></div>
        <div class="panelTop"></div>
        <div class="panelMiddle padLR20">
            <div class="shortTitleLabel">Results</div>
            <div class="floatRight inline marginT5">
                <div class="inline">Number of results in each page: </div>
                <%= Html.DropDownList("PageSize", (SelectList)ViewData["pageSizes"], new { @class = "pageSizeList", onchange = "javascript:location.href='?pageSize=' + this.options[this.selectedIndex].value" })%>
            </div>
            <% foreach (var item in Model.Results) { %>
                <div class="result green" onmouseover="highlightResult(this)" onclick="location.href='/Job/ViewJob/<%= item.JobId %>'" onmouseout="normalResult(this)" title="Click to view this job position.">
                    <b><%= Html.Encode(item.JobTitle) %></b> (<%= Html.Encode(item.JobSector) %>)
                    <div class="floatRight">
                        <span class="small">Closing date: <span class="red"><b><%= Html.Encode(item.ClosingDate)%></b></span></span>&nbsp;
                        <% if (ViewData["role"].ToString() == "JobProvider" || ViewData["role"].ToString() == "Admin") { %>
                            <%= Html.ActionLink("Edit", "Edit", new { id = item.JobId })%> |
                            <%= Html.ActionLink("Delete", "Delete", new { id = item.JobId })%>
                        <% } %>
                    </div>
                </div>
            <% } %>
            <% if (Model.TotalResultCount == 0) { %>
                <div class="floatLeft clear">There are no Job positions that match that search selection.</div>
            <% } else { %>
                <div class="floatLeft inline marginT10 clear">Showing <%= Model.PageSize > Model.TotalResultCount ? Model.TotalResultCount : Model.PageSize%> out of <%= Model.TotalResultCount %> results.</div>
                <div class="pager">
                    Page number <%= Model.PageNumber %> out of <%= Math.Ceiling((decimal)Model.TotalResultCount / Model.PageSize)%> <%= Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalResultCount) %>
                </div>
            <% } %>
        </div>        
        <div class="panelBottom"></div>
    <% } %>    
</asp:Content>